package com.glh.javalogic.chapter4.doubleedged;

/**
 * <pre>
 *     author : 高磊华
 *     e-mail : 984992087@qq.com
 *     time   : 2018/08/18
 *     desc   : 子类 (继承是把双刃剑)====>使用组合实现子类
 *     version: 1.0
 * </pre>
 */
public class ChildV2 {

    private BaseV1 mBaseV1;

    private long sum;

    public ChildV2() {
        mBaseV1 = new BaseV1();
    }

    public void add(int number) {
        mBaseV1.add(number);
        sum += number;
    }


    public void addAll(int[] numbers) {
        mBaseV1.addAll(numbers);
        for (int i = 0; i < numbers.length; i++) {
            sum += numbers[i];
        }
    }

    public long getSum() {
        return sum;
    }
}